<template>
	<view class="fault-content">
		<view class="fault-title">故障现象</view>
		<view class="fault-list">
			<view>
				<text>线路</text>
				<text>{{infoDetail.lineName}}</text>
				<hr>
			</view>
			<view>
				<text>站名</text>
				<text>{{infoDetail.staName}}</text>
				<hr>
			</view>
			<view class="fault-list-item">
				<text>故障现象</text>
				<view>{{infoDetail.content}}</view>
				<hr>
			</view>
			<view>
				<text>故障代码</text>
				<text>{{processCodeValue}}</text>
				<hr>
			</view>
			<view>
				<text>故障级别</text>
				<text>{{infoDetail.faultTypeName}}</text>
				<hr>
			</view>
			<!-- <view>
				<text>供应商</text>
				<text>15号线</text>
				<hr>
			</view> -->
		</view>
	</view>
</template>

<script>
	export default {
		name: "faultInfo",
		data() {
			return {
				infoDetail: "",
				processCodeValue: "",
				boardList: [{
					name: '告警'
				}, {
					name: '调度发布'
				}, {
					name: '指挥发布'
				}, {
					name: '接警'
				}, {
					name: '派单'
				}, {
					name: '接单'
				}, {
					name: '到场'
				}, {
					name: '已解决'
				}],
			};
		},
		props: ["httpParams"],
		created() {
			this.initDetail();
		},
		methods: {
			initDetail() {
				this.infoDetail = this.$store.state.faultInfoGlobal;

				let processCode = this.$store.state.faultInfoGlobal.processCode
				if (processCode < 7) {
					this.processCodeValue = Object.values(this.boardList[processCode])[0];
				} else {
					this.judgeProcessFinal();
				}

				// let faultId = this.httpParams.faultId
				// this.fetch('GET', this.$store.state.baseEmerUrl + '/emergency/processes/' + faultId, {}, true).then((res) => {
				// })
			},
			judgeProcessFinal() {
				let faultId = this.httpParams.faultId
				this.fetch('GET', this.$store.state.baseEmerUrl + '/emergency/processes/' + faultId, {}, false).then((
					res) => {
					if (res.success && res.data && res.data.length) {
						let unData = res.data;
						this.processCodeValue = unData[unData.length - 1].processCode == 8 && unData[unData
								.length - 1].contentJson ? JSON.parse(unData[unData.length - 1].contentJson)
							.status : '已解决';
					} else {
						console.error(res)
					}
				})
			},
		}
	}
</script>

<style scoped lang="less">
	.fault-content {
		.fault-title {
			font-size: 32upx;
			margin-left: 40upx;
			margin-bottom: 20upx;
			color: #929292;
		}

		.fault-list {
			background-color: white;
		}

		.fault-list>view {
			font-size: 34upx;
			height: 100upx;

			text:nth-child(1) {
				color: #7e7e7e;
				margin-left: 50upx;
			}

			text:nth-child(2) {
				float: right;
				color: black;
				margin-right: 40upx;
			}

			hr {
				margin-top: 20upx;
				border: 0;
				border-top: 2px solid #f1f1f1;
			}
		}

		.fault-list>.fault-list-item {
			height: auto;
			margin-bottom: 16upx;

			view {
				padding-left: 250upx;
			}
		}

		.fault-list>view:first-child {
			height: 132upx;
			padding-top: 30upx;
		}

		.fault-list>view:last-child {
			height: 66upx;
		}
	}
</style>